<%-- 
    Document   : prova
    Created on : 5-apr-2013, 9.29.49
    Author     : Giuseppe
--%>


<%@page import="java.util.LinkedList"%>
<%@include file="wrapper.jsp" %>
<%@page import="java.util.List"%>
<%@page import="ejb.Utente"%>
<%@page import="ejb.ArticoloNuovo"%>
<%@page import="ejb.ArticoloUsato"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%
    Utente utSession = (Utente)session.getAttribute("utente");
    String tipo = utSession.getTipo();
    Integer totCarrello=0;
    LinkedList<ArticoloNuovo> carrello = (LinkedList<ArticoloNuovo>)session.getAttribute("carrello");
    List<ArticoloUsato> usatiDaConfermare= (List<ArticoloUsato>)session.getAttribute("usatiDaConfermare");
%>
<div class="container">
    <div class="row-fluid">
    <div class="span3 bs-docs-sidebar">
        <ul class="nav nav-list bs-docs-sidenav">
            <li><a href="Controller?button=visualizzaArticoli&amp;typeView=All"> 
            <button class="btn btn-large btn-inverse btn-block btn-success"><i class="icon-white icon-th-list"></i> Tutti gli articoli</button> </a></li>
            <li><a href="Controller?button=visualizzaArticoli&amp;typeView=Mine"> 
            <button class="btn btn-large btn-inverse btn-block btn-success"><i class="icon-white icon-user"></i> I miei articoli</button> </a></li>
            
        </ul>
      </div>
    <div class="span6">
    <div class="thumbnail">
    <h3>Vendi Articolo Usato</h3>
    <form class="form-horizontal" action="Controller" method="POST" onsubmit="return checkUsed(this)">
    <div class="control-group">
    <label class="control-label" for="inputNome">Nome:</label>
    <div class="controls">
      <input name="nomeArtUsato" type="text" id="inputNome" placeholder="Nome">
    </div>
    </div>    
     <div class="control-group">
    <label class="control-label" for="inputDescr">Descrizione generale:</label>
    <div class="controls">
        <textarea name="descrizioneArtUsato" id="inputDescr" placeholder="Descrizione generale" rows="5"></textarea>
    </div>
    </div>   
    <div class="control-group">
    <label class="control-label" for="inputPrezzo">Prezzo:</label>
    <div class="controls">
      <input name="prezzoArtUsato" type="text" id="inputPrezzo" placeholder="Prezzo">
    </div>
    </div> 
    <div class="control-group">
    <label class="control-label" for="inputComm">Commento:</label>
    <div class="controls">
    <textarea name="commentoArtUsato" id="inputComm" placeholder="Commento" rows="5"></textarea>
    </div>
    </div>   
    <div class="control-group">
    <label class="control-label" for="inputPath">Percorso immagine:</label>
    <div class="controls">
        <input id="immagine" type="file" style="display:none">
        <div class="input-append">
            <input id="pathImmagine" readonly="readonly" class="input-large" type="text" style="width:150px" name="pathImmagine" placeholder="Percorso">
            <a class="btn btn-inverse" onclick="$('input[id=immagine]').click();">Cerca File</a>
        </div>
        <script type="text/javascript">
            $('input[id=immagine]').change(function() {
                var path=$(this).val();
//                var toRemove=path.substr(0,12);
//                var pathClear=path.replace(toRemove,'');
                  $('#pathImmagine').val(path);
//                $('#pathImmagine').val(pathClear);
            });
            
          
        </script>
        
    </div>
    </div>
 <label id="erroreDati" style="padding-left: 140px;color: red;"></label>
    <div class="control-group">
    <label class="control-label" style="padding-left: 140px">
        <button class="btn btn-inverse btn-small btn-success" type="submit" value="inserisciArtUsatoUtente" name="button"><i class="icon-white icon-ok"></i> Metti in vendita</button>
    </label>
    </div>    

 

    </form>
</div>
</div>
<div class="span3">
            <%
            if(tipo.equals("u")){
            %>
            <div class="thumbnail">
                  <p><b>Carrello</b></p>
                  <table>
                  <tr><td></td><td style="padding-left: 5px"><b>Articolo</b></td><td style="padding-left: 5px"><b>Costo</b></td></tr>
                  <tr><td><br></td><td><br></td><td><br></td></tr>
                  <% 
                  for(ArticoloNuovo a:carrello){
                      totCarrello= totCarrello + a.getPrezzo();
                  %>
                  <tr>
                  <p>
                   <td>
                        <a href="Controller?button=removeCarrello&amp;idArticolo=<%=a.getId()%>">
                            <button class="btn btn-inverse btn-mini"><i class="icon-white icon-trash"></i></button>
                        </a>
                    </td>
                  <td style="padding-left: 5px;height: 20px;width:100%;overflow:hidden;float:left"><%=a.getNome()%></td>
                  <td style="padding-left: 5px"><%=a.getPrezzo().toString()%> €</td>
                  </p>
                  </tr>
                  <tr><td><br></td><td><br></td><td><br></td></tr>
                  <%}%>
                  <tr><td></td><td><b>Totale</b></td><td style="padding-left: 5px"><%=totCarrello.toString()%> €</td></tr>
                  </table>
              </div>
              
            <%}
            else if(tipo.equals("a")){%>
            <div class="thumbnail">
                 <p><b>Notes</b></p>
                 <br>
                 <% if(!usatiDaConfermare.isEmpty()){%>
                    <p> Ancora <%=usatiDaConfermare.size()%> articoli da confermare </p>
                    <br>
                    <p align="center">
                        <a href="Controller?button=modificaCancellaArtUsati&amp;confirm=s">
                            <button class="btn btn-inverse btn-small"><i class="icon-white icon-th-list"></i> Vedi Articoli da confermare</button>
                        </a>
                    </p>
                 <%}else{%>
                 <p> Nessun articolo da confermare </p>
                <%}%>      
            </div>
           <%}%>
         </div>    
</div>
</div>
</body>


</html>
